FROM debian:buster-slim

ENV LANG='zh_CN.UTF-8' LANGUAGE='zh_CN.UTF-8' LC_ALL='zh_CN.UTF-8'
# COPY slim-java* /usr/local/bin/
#******************更换Alpine源为mirrors.ustc.edu.cn******************
RUN set -eux; \
    #改国内源 阿里云
    sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list; \
    sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list; \
    apt-get update; \
    apt-get install -y --no-install-recommends tzdata curl ca-certificates fontconfig locales; \
    apt-get install -y --no-install-recommends wget unzip; \
    echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen; \
    locale-gen zh_CN.UTF-8; \
    # rm -rf /var/lib/apt/lists/*; \
    #改时区
    echo "Asia/Shanghai" > /etc/timezone; \
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime; \
    echo "TZ='Asia/Shanghai'; export TZ" >> /root/.profile; \
    \
    ARCH="$(uname -m)"; \
    case "${ARCH}" in \
       aarch64|arm64) \
         ESUM='8353d3b2ad6929592e7b6acc162d0622e2a1128868607849bb904db49de80e07'; \
         BINARY_URL='https://bkjump.mvaas.cn/dbconn/softtools/jdk/jdk-8u271-fcs-bin-b09-linux-aarch64-16_sep_2020.tar'; \
         ;; \
       amd64|x86_64) \
        #  ESUM='4211bc4fe4b7fca1acabca75082fd3d968ad306a50e44e68c22bca3149c710ae'; \
        #  BINARY_URL='https://bkjump.mvaas.cn/dbconn/softtools/jdk/jre-8u271-linux-x64.tar.gz'; \
         ESUM='eacee7bd4b99185722cbb3ca8a352f04076c0196fec822453a2f2cbe5058f174'; \
         BINARY_URL='https://bkjump.mvaas.cn/dbconn/softtools/jdk/jdk-8u271-linux-x64.tar'; \
         ;; \
       *) \
         echo "Unsupported arch: ${ARCH}"; \
         exit 1; \
         ;; \
    esac; \
    wget -O /tmp/openjdk.tar.gz ${BINARY_URL}; \
    echo "${ESUM} */tmp/openjdk.tar.gz" | sha256sum -c -; \
    mkdir -p /opt/java/openjdk; \
    cd /opt/java/openjdk; \
    tar -xf /tmp/openjdk.tar.gz --strip-components=1; \
    # export PATH="/opt/java/openjdk/bin:$PATH"; \
    # apt-get update; apt-get install -y --no-install-recommends binutils; \
    # /usr/local/bin/slim-java.sh /opt/java/openjdk; \
    # apt-get remove -y binutils; \
    rm -rf /var/lib/apt/lists/*; \
    rm -f src.zip; \
    rm -f javafx-src.zip; \
    rm -rf COPYRIGHT LICENSE README release THIRDPARTYLICENSEREADME-JAVAFX.txtTHIRDPARTYLICENSEREADME.txt Welcome.html; \
#     rm -rf lib/plugin.jar \ 
# 　　 lib/ext/jfxrt.jar \ 
# 　　 bin/javaws \ 
# 　　 lib/javaws.jar \ 
# 　　 lib/desktop \ 
# 　　 plugin \ 
# 　　 lib/deploy* \ 
# 　　 lib/*javafx* \ 
# 　　 lib/*jfx* \ 
# 　　 lib/amd64/libdecora_sse.so \ 
# 　　 lib/amd64/libprism_*.so \ 
# 　　 lib/amd64/libfxplugins.so \ 
# 　　 lib/amd64/libglass.so \ 
# 　　 lib/amd64/libgstreamer-lite.so \ 
# 　　 lib/amd64/libjavafx*.so \ 
# 　　 lib/amd64/libjfx*.so; \
    rm -rf /tmp/openjdk.tar.gz;

#******************设置JAVA变量环境******************
ENV JAVA_HOME=/opt/java/openjdk \
    PATH="/opt/java/openjdk/bin:$PATH" \
    CLASSPATH=$JAVA_HOME/bin \
    JAVA_VERSION=jdk8u271
CMD ["java","-version"]
